<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title><{$title}> - <{$title_desc}></title>
<link rel="shortcut icon" href="../favicon.gif" type="image/gif" />
<link rel="stylesheet" href="<{$env.app.res_url}>/framework.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="<{$env.app.res_url}>/component.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="<{$env.app.res_url}>/button.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="<{$env.app.res_url}>/form.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="<{$env.app.res_url}>/gridlist.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="<{$env.app.res_url}>/style.css" type="text/css" media="screen, projection"/>
<{foreach from=$theme_css item="desktop_theme_css_file"}>
<link rel="stylesheet" href="<{$desktop_theme_css_file}>" type="text/css" media="screen, projection"/>
<{/foreach}>
<{lang_css src="lang.css" app="desktop"}>
<{desktop_header}>

<{assign var=desktop_sideleft value="desktop_{$uname}_sideleft"}>
<script>
   startTime = (new Date).getTime();

   currentWorkground = null;

  /*商店事件、状态 推送包*/
   shopeEvents = {};
   SESS_ID=null;
   SHOPBASE='<{$shop_base}>';
   SHOPADMINDIR='<{$shopadmin_dir}>';
   DESKTOPRESURL='<{$env.app.res_url}>';
   DESKTOPRESFULLURL='<{$env.app.res_full_url}>';
   CURRENTUSER =  '<{$uname}>';
   BREADCRUMBS ='0:0';
   window.loadedPart = [1,0,(new Date).getTime()];
</script>
</head>
<body>
<noscript>
  <div class='noscript error'>
    <{t}>您好，要正常运行ShopEx后台，浏览器必须支持Javascript<{/t}>
  </div>
</noscript>

<div class='loadpart' id='loadpart'>
   <div class='msg'><{t}>正在加载...<{/t}></div>
   <div class='lpb'>
      <div class='lpp' id='loadpartprocess' style='height:5px;overflow:hidden;width:0px'>&nbsp;</div>
   </div>
</div>

<iframe src='<{$env.app.res_url}>/tpl.html' id='tplframe' class='hide' tabindex='-1' ></iframe>
<iframe src='<{$env.app.res_url}>/about.html' name='download' tabindex='-2' id='downloadframe' class='hide'></iframe>
<iframe src='<{$env.app.res_url}>/about.html' name='upload' tabindex='-2' id='uploadframe' class='hide'></iframe>

<div class="wrapper" id='body' style='visibility:hidden'>
  <div class="msgbox" id="messagebox"></div>
  <div class="header" id="header">
    <div class="header-inner clearfix">
      <div class="top-bar clearfix" id="topbar">
        <div class="span-7">
          <h1 class="logo">
            <a href="index.php?ctl=dashboard&act=index"><{$env.conf.desktop.banner}></a>
            <span id="license" class="head-license">
            <a target="_black" href="<{$certificate_url}>">
              <img img-lazyload="<{$open_api_url}>"  alt="ShopEx CERT INFO" />
              </a>
            </span>
          </h1>
        </div>
        <div class="head-user frt">
		 <div class="span-auto"><span>|</span> </div>
          <{$uname}>
          [<a href="index.php?ctl=dashboard&act=profile" target="dialog::{width:463,height:280,title:'<{t}>管理员信息<{/t}>'}" ><{t}>设置<{/t}></a>]
          [<a href='index.php?ctl=passport&act=logout' target='_top'><{t}>退出<{/t}></a>]
        </div>
		
        <div class="head-opts frt">
          <div class="frt">
            <{$desktop_menu}>
          </div>
          <div class="rpcnotify frt" style="display:none">
            <a href='index.php?ctl=rpcnotify&act=index'><{t}>系统通知<{/t}></a><i class="notify_num"></i>
            <span>|</span>
          </div>
          <div class="frt"><span>|</span> </div>
          <div class="frt">
	          	<div class="favor" id="favor">
	          		<span class="favor-handle">快捷菜单</span>
	          		<div class="x-drop-menu" style="display:block;visibility:hidden;">
			            <ul>
			              <{foreach from=$shortcuts_menus item=item key=key}>
			              <li>
			                <a href="index.php?<{$item}>"><span><{$key}></span></a>
			              </li>
			              <{/foreach}>
			              <li <{if count($shortcuts_menus)}>class="clear"<{/if}>>
			               <a onclick="new Dialog('index.php?app=desktop&ctl=default&act=allmenu',{'title':'<{t}>快捷菜单配置<{/t}>'})" href="javascript:void(0)"><span><{t}>点此编辑快捷菜单<{/t}></span></a>
			               
			              </li>
			            </ul>
			         </div>
	          	</div>
          </div>
        </div>
      </div>
    </div>

    <div class="head-nav clearfix">
      <div class="flt">
        <{foreach from=$fav_menus item=item  key=key}>
        <{assign var=menu_group value=$menus.menu.$item}>
        <dl>
          <dt>
            <a href="index.php?<{$menus.workground.$item.menu_path}>" class="wg" mid="<{$menus.workground.$item.menu_id}>"><span><{$menus.workground.$item.menu_title}></span></a>
          </dt>
          <dd>
          <ul>
            <{foreach from=$menu_group item=groups name=groups0 key=key1}>
            <li <{if $env.foreach.groups0.last}>class="last"<{/if}>>
            <{if $key1=='nogroup'}>
            <{foreach from=$groups item=group name=groups1}>
            <li <{if $env.foreach.groups1.last}>class="last"<{/if}>>
              <a href="index.php?<{$group.menu_path}>" <{if $group.target}> target="<{$group.target}>"<{/if}>><span><{$group.menu_title}></span></a>
            </li>
            <{/foreach}>
            <{else}>
            <a class="head-nav-sub" href="javascript:void(0)"><span><{$key1}></span></a>
            <ul>
              <{foreach from=$groups item=group name=groups2}>
              <li <{if $env.foreach.groups2.last}>class="last"<{/if}>>
                <a href="index.php?<{$group.menu_path}>" <{if $group.target}> target="<{$group.target}>"<{/if}>><span><{$group.menu_title}></span></a>
              </li>
              <{/foreach}>
            </ul>
            </li>
            <{/if}>
            <{/foreach}>
          </ul>
          </dd>
        </dl>
        <{/foreach}>
      </div>
      <div class="span-auto">&nbsp;</div>
      <div class="flt">
        <dl class="head-nav-setting" id="head-nav-setting" style="visibility:hidden;">
          <dt>
            <a href="index.php?app=desktop&ctl=default&act=main_menu_define" target="dialog::{title:'<{t}>菜单定制<{/t}>',width:350,height:0.7}"><span><{t}>菜单定制<{/t}></span>
            	&nbsp;<{img src="bundle/control.gif"}>
            </a>
          </dt>
        </dl>
      </div>
    </div>
  </div>

  <div class="container clearfix" id="container">
	
    <div class="side <{if $env.cookie[$desktop_sideleft] == 'OFF-SHOW'}>hide<{/if}>" id="side">
      <div class="side-inner">
        <div class="side-content">

        </div>
      </div>
    </div>

    <div class="toggler-left flt" id='leftToggler'>
      <a href="javascript:void(0)" class="toggler-left-inner" title="<{t}>点击收起或展开左侧<{/t}>">&nbsp;</a>
    </div>
    
    <div class='workground' id='workground'>
      <div class='content-head'></div>
      <div class='content-main' id='main'>
        loading...
      </div>
      <div class='content-foot'></div>
    </div>

    <div class="side-r hide" id="side-r">
      <div class="side-r-top clearfix">
        <b class="side-r-title flt f-14"></b>
        <span class="frt side-r-close pointer"><{img src="bundle/finder_drop_arrow_close.gif"}></span>
      </div>
	  <div class="side-r-head" style="border-bottom:1px #999 solid;padding:2px 0 2px 0;">
	  </div>
      <div id="side-r-content" class="side-r-content" conatainer="true" style="overflow:auto">
      </div> 
	  <div class="side-r-foot">
      </div>
    </div>
  </div>
</div>

<script>
void function(){
	var win_loaded = false;
	this.loadedPart[0] += this.frames.length;
	var loadedCall = function(){
		if(win_loaded)return;
		(loadedPart[1])++;
		win_loaded = loadedPart[1];
	};
	window.onload = loadedCall;
	if('addEventListener' in document)
	document.addEventListener('DOMContentLoaded',loadedCall,false);
}();

var st=0;
(function(){
    if(loadedPart[1]==loadedPart[0]){
        clearTimeout(st);
        document.getElementById('loadpart').style.display='none';
        document.getElementById('body').style.visibility='visible';
        return initDefaultPart();
    }
    document.getElementById('loadpartprocess').style.width = (loadedPart[1]/loadedPart[0])*100+'%';
    st = setTimeout(arguments.callee, loadedPart[3] - startTime+100);
})();
</script>
<{lang_script src="lang.js"}>
<{script src="moo.js" }>
<{script src="moomore.js" }>
<{script src="mooadapter.js" }>
<{script src="jstools.js" }>
<{script src="coms/hst.js" }>
<{script src="coms/messagebox.js" }>
<{script src="coms/dialog.js" }>
<{script src="coms/validate.js" }>
<{script src="coms/wpage.js" }>
<{script src="coms/finder.js" }>
<{script src="coms/lazyload.js" }>
<{script src="coms/dropmenu.js" }>
<{script src="coms/cmdrunner.js" }>
<{script src="coms/datapicker.js" }>
<{script src="coms/colorpicker.js" }>
<{script src="coms/modedialog.js" }>
<{script src="coms/editor.js" }>
<{script src="coms/editor_style_1.js" }>
<{script src="coms/uploader.js"}>
<{script src="coms/autocompleter.js" }>
<{script src="fixie6.js" }>
<script>
var LAYOUT = {
    head: $('header'),
    container: $('container'),
    side: $('side'),
    workground: $('workground'),
    content_main: $('main'),
    content_head: $E('#workground .content-head'),
    content_foot: $E('#workground .content-foot'),
    side_r: $('side-r'),
    side_r_content:$('side-r-content'),
    leftToggler:$('leftToggler')
};

/*
申请LICENSE_CENTER
*/

/*init  script

this Function will run at 'loadedPart[1]==loadedPart[0]'
*/
var initDefaultPart = function() {
	
	
    
	fixLayout = function() {
		//console.log(new Date);
		var winSize = window.getSize();
        var _NUM = function(num){
            num =  isNaN(num)?0:num;
            if(num<0)num=0;
            return num;
        };

		if(winSize.x<798){
			$('body').setStyles({'width':798});
		}else{
			$('body').setStyles({'width':''});
		}
        var containerHeight = winSize.y - LAYOUT.head.getSize().y;

        LAYOUT.container.setStyle('height',_NUM(containerHeight-LAYOUT.container.getPatch().y));
        LAYOUT.container.setStyle('width',_NUM(winSize.x.limit(960, 2000)));

        LAYOUT.content_main.setStyle('height',
            _NUM(containerHeight -
            LAYOUT.content_head.getSize().y  -
            LAYOUT.content_foot.getSize().y  -
            LAYOUT.workground.getPatch().y)
        );

		if(!LAYOUT.side.hasClass('hide')){
        	LAYOUT.side.setStyle('width',_NUM( (winSize.x * 0.12).limit(150,winSize.x)));
		}
		
        if(!LAYOUT.side_r.hasClass('hide')){
			if(!LAYOUT.side_r.get('widthset'))
	            LAYOUT.side_r.setStyle('width',_NUM((winSize.x*0.12).limit(150,winSize.x)));
	        LAYOUT.side_r_content.setStyle('height',
	            _NUM(containerHeight-
				LAYOUT.side_r.getElement('.side-r-top').getSize().y-
	            LAYOUT.side_r.getElement('.side-r-head').getSize().y-
				LAYOUT.side_r.getElement('.side-r-foot').getSize().y-
	            LAYOUT.side_r_content.getPatch().y-
				LAYOUT.side_r.getPatch().y)
	        );
		}

        LAYOUT.workground.setStyle('width',_NUM(
            (winSize.x - LAYOUT.workground.getPatch().x)-
            LAYOUT.leftToggler.getSize().x-
            LAYOUT.side.getSize().x-
            LAYOUT.side_r.getSize().x)
        );


      LAYOUT.content_main.setStyle('width',_NUM(LAYOUT.workground.getSize().x-LAYOUT.workground.getPatch().x));
        

    };
    window.addEvents({
        'resize': fixLayout
    });

    //window.fireEvent('resize');

   
    Side_R = new Class({
        Implements: [Options, Events],
        options: {
            onShow: $empty,
            onHide: $empty,
            onReady: $empty,
            width:false
        },
        initialize: function(url, opts) {
            this.setOptions(opts);
            this.panel = $('side-r');
            this.container = $('side-r-content');
			var trigger = this.options.trigger;
            if(trigger){			
                if(!trigger.retrieve('events',{})['dispose'])   
				
                trigger.addEvent('dispose',function(){
                    $('side-r').addClass('hide');
                    $('side-r-content').empty();
                    $('side-r').removeProperty('widthset').store('url','');
                });
            }

            if(this.panel.retrieve('url','') == url)return;
            if (url) {
                this.showSide(url);
            } else {
                throw Exception('NO TARGET URL');
                return;
            }

            var btn_close = this.panel.getElement('.side-r-close');
            var _title = this.panel.getElement('.side-r-title');

            _title.set('html',this.options.title||"");

            if(btn_close){
                btn_close.removeEvents('click').addEvent('click', this.hideSide.bind(this));
            }

        },
        showSide: function(url) {
            this.cleanContainer();

            var _this = this;
            if(_this.options.width){
                _this.panel.set({'widthset':_this.options.width,styles:{width:_this.options.width}});
            }
            _this.panel.removeClass('hide');
            window.fireEvent('resize');
            _this.fireEvent('show');

            W.page(url,{
                update:_this.container, 
			    render:false,
                onRequest: function() {
                    _this.panel.addClass('loading');
                },
                onComplete: function() {
                    _this.panel.removeClass('loading');
                    _this.fireEvent('ready', $splat(arguments));
                    _this.panel.store('url',url);
                }
            });
        },
        hideSide: function() {
            this.panel.addClass('hide');
            window.fireEvent('resize');
            this.cleanContainer();
            this.fireEvent('hide');
        },
        cleanContainer: function() {
            this.panel.removeProperty('widthset').store('url','');
            this.container.empty();
        }
    });

    /*MODAL PANEL*/
    MODALPANEL = (function() {
        var mp = $pick($('MODALPANEL'), new Element('div', {
            'id': 'MODALPANEL'
        }).inject(document.body)).setStyle('display', 'none');
        var mpStyles = {
            'position': 'absolute',
            'background': '#333333',
            'width': '100%',
            'height': window.getScrollSize().y,
            'top': 0,
            'left': 0,
            'zIndex': 65500,
            'opacity': .4
        };
        mp.setStyles(mpStyles);
        mp.addEvent('onshow',
        function(el) {
            el.setStyles({
                'width': '100%',
                'height': window.getScrollSize().y
            });
        });
        return mp;
    })();

    window.addEvent('resize',
    function() {
        MODALPANEL.setStyles({
            'width': '100%',
            'height': window.getScrollSize().y
        });
    });



    $('leftToggler').addEvent('click',function(e) {
        if(this.hasClass('fixed'))return;
        
		LAYOUT.side.toggleClass('hide');
		
        var fcokk =  'desktop_'+CURRENTUSER+'_sideleft';
        if(!LAYOUT.side.hasClass('hide')){
            Cookie.dispose(fcokk);
            }else{
            Cookie.write(fcokk,'OFF-SHOW',{duration:365});
        }
		fixSideToggler();
        window.fireEvent('resize');
    });

	var fixSideToggler = (function(){
		LAYOUT.side.hasClass('hide')?$('leftToggler').getElement('.toggler-left-inner').addClass('hide'):				 $('leftToggler').getElement('.toggler-left-inner').removeClass('hide');
		return arguments.callee;
	})();

    fixSideLeft = function(act){
        $('leftToggler')[act+'Class']('fixed');
        if(Cookie.read('desktop_'+CURRENTUSER+'_sideleft'))return;
        LAYOUT.side[act+'Class']('hide');
        window.fireEvent('resize');
    };
	/*快捷菜单处理*/
	
	$('favor').addEvents({
		'mouseenter':function(){
			this.addClass('favor-active');
			this.getElement('.x-drop-menu').setStyles({
				top:this.getElement('.favor-handle').offsetHeight-1,
				left:0,
				visibility:'visible'
			});
		},
		'mouseleave':function(){
			this.removeClass('favor-active');
			this.getElement('.x-drop-menu').setStyles({
				visibility:'hidden'
			});
			
		}
	});
	
	
	void function(){
		var winSize = window.getSize();
		var dmenu = $('favor').getElement('.x-drop-menu');
		dmenu.setStyle('width',winSize.x-$('favor').getPosition().x-dmenu.getPatch().x - 7);
		var favs = $$('#favor li');
			favs.pop();
	    new Equalizer(favs).equalize('width');
	
	
		$('topbar').setStyle('background-position',$('favor').getPosition().x-35+'px -3px');
	}();
	
	
	  
   /*顶部菜单处理*/ 
   void function(){
 	var _timer = 0;
	var _mouse = true;
	var _absoluteFix =  function(f,t){
	      var pos =  {}; 
	
	      var fcis = f.getCoordinates();
	      var tsize = t.getSize();
		  var wsize = window.getSize();
	      if((wsize.x-fcis.right)<tsize.x){
		    $extend(pos,{left:Math.abs(fcis.right-tsize.x),top:fcis.bottom});  
		  }else{
			$extend(pos,{left:fcis.left,top:fcis.bottom});
		  }
		  
	
	      return pos;
	}
    var getCurWgMenu =function(){return LAYOUT.head.getElement('a[mid='+BREADCRUMBS.split(":")[0]+']');}
    var lis = $$('.head-nav dl ul li li').addEvent('click',function(){
	       this.getParent('dl').fireEvent('mouseleave');
		   _mouse=false; 
    });
    new Equalizer(lis).equalize('width');//等宽
    
    $$('.head-nav')[0].addEvents({
    	'mouseenter':function(){	
    			$('head-nav-setting').fade(1);
    	},
    	'mouseleave':function(){
    		    $('head-nav-setting').fade(0);
    	}
    });
    
	$$('.head-nav dl').addEvents({
		
		'mouseenter':function(){ 
			_mouse=true;
			$clear(_timer);
			
			 var dd = this.getElement('dd');
			 if(!dd)return;  
		        if(wg = this.getElement('.wg')){
					if(cwg = getCurWgMenu()){
			 		    if(wg.uid!=cwg.uid){ 
						  
						  cwg.removeClass('current');
						   
				       }
				    }   
					wg.addClass('current');
		            
				}
				
				
				 dd.setStyle('visibility','visible');
			     dd.setStyles(_absoluteFix(this,dd));
			
		},
		'mouseleave':function(e){
			if(!_mouse)return;  
			var dd = this.getElement('dd');
						 if(!dd)return;
			var cwg = getCurWgMenu();    
			     if(wg = this.getElement('.wg')){
				     if(cwg&&e){
			 		    if(wg.uid!=cwg.uid){
						  _timer = cwg.addClass.delay(200,cwg,'current');
						  wg.removeClass('current'); 
				        }
				     }else{      
					  
					   wg.removeClass('current'); 
				     }
		         }
		
				 dd.setStyle('visibility','hidden'); 

			     //dd.setPosition(this);
			
		}
		
		
	}); 
 }();
   

	
   

        /*每 30秒 同步一下后台 的事项*/
    EventsRemote = {
        url: "index.php?ctl=default&act=status",
        timer: 30000,
        delay: 0,
        stop:function(){
        	$clear(this.delay);
        },
        start:function(){
        	this.delay = this.doit.delay(this.timer, this);
        },
        init: function() {
            var _this = this;
            this.request = (new Request.HTML({
				url:this.url,
                onSuccess: function(nodes, elements, responsetext, javascript) {
                    $clear(_this.delay);
                    _this.delay = _this.doit.delay(_this.timer, _this);
                },
                onCancel: function() {
                    _this.delay = _this.doit.delay(_this.timer, _this);
                },
                onFailure: function() {
                    _this.delay = _this.doit.delay(_this.timer * 2, _this);
                }
            }));
            return this;
        },
        doit: function(_chain) {
	
			_chain =$type(_chain)=='function'?_chain : $empty;

            return this.request.post({
                events: shopeEvents
            }).chain(_chain);
        }
    };
    EventsRemote.init().start();

    new LazyLoad({IE_show_alt:true}).loadCustomLazyData($('topbar'),'img');

	
	
	
	W = new Wpage();
    W.render(document.body);
    Xtip = new Tips();
 

};//function end;


function _get_rpcnotify_num(obj) {
    W.page('index.php?app=desktop&ctl=rpcnotify&act=read',{method:'POST',onComplete:function(){
				var notify=$E('#topbar .notify_num');
                if(notify){
                    var msg=notify.get('text'),n;
                    n=msg.substring(1,msg.length-1);
                    n=n-1>0?'('+(n-1)+')':'';
                    notify.set('text',n);
                }
            },data:{id:$(obj).getParent('tr').getElement('input').get('value')}
       });
}

</script>
<{foreach from=$theme_scripts item="desktop_theme_js"}>
<script type="text/javascript" src="<{$desktop_theme_js}>"></script>
<{/foreach}>
<{desktop_footer}>
</body>
</html>
